package com.zjz.studynotes.db;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;

import com.zjz.studynotes.ListStringConverter;
import com.zjz.studynotes.bean.LoginUserInfo;
import com.zjz.studynotes.bean.StudyNoteInfo;
import com.zjz.studynotes.dao.LoginUserInfoDao;
import com.zjz.studynotes.dao.StudyNoteInfoDao;

/**
 * Description: 数据库
 * Author: zjz
 * Date:2025/5/5 13:40
 */
@Database(entities = {LoginUserInfo.class, StudyNoteInfo.class}, version = 1, exportSchema = false)
@TypeConverters({ListStringConverter.class})
public abstract class StudyNotesDb extends RoomDatabase {

    public abstract LoginUserInfoDao getLoginUerInfoDao();
    public abstract StudyNoteInfoDao getStudyNoteInfoDao();
    public static StudyNotesDb studyNotesDb;


    public static StudyNotesDb getInstance(Context context) {
        if (studyNotesDb == null) {
            studyNotesDb = Room.databaseBuilder(context.getApplicationContext(), StudyNotesDb.class, "study-notes")
                    .allowMainThreadQueries().build();
        }

        return studyNotesDb;
    }
}
